package ace.module.account.oauth2.sdk.core.feign.impl;

import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.account.oauth2.api.IamOauth2CallbackAuthenticationApi;
import ace.module.account.oauth2.api.model.input.IamOauth2CallbackAuthenticationInput;
import ace.module.account.oauth2.sdk.core.constants.SdkConstant;
import ace.module.common.api.annotation.ApiRemoteImplementPriority;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.oauth2.server.api.model.dto.ext.Oauth2AceAuthResultDto;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 账户认证 oauth2 callback rpc contract.
 *
 * @author caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.iamOauth2CallbackAuthenticationFeign.name:"
        + SdkConstant.FEIGN_SERVICE_NAME
        + "}",
    contextId = "iamOauth2CallbackAuthenticationFeign",
    path = IamOauth2CallbackAuthenticationFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface IamOauth2CallbackAuthenticationFeign extends IamOauth2CallbackAuthenticationApi {

  String PATH =
      "${spring.cloud.openfeign.client.iamOauth2CallbackAuthenticationFeign.path:/account/oauth2/rpc}";

  @PostMapping("/authentication")
  Oauth2AceAuthResultDto authentication(
      @Valid @NotNull @RequestBody IamOauth2CallbackAuthenticationInput input);
}
